package com.wyh.utils.sqlUtils.house;

import com.wyh.entity.Houses;

import javax.validation.constraints.NotNull;

public class updateHouseSqlDynamic {
    public String updateDynamic(@NotNull Houses houses) {
        StringBuilder builder = new StringBuilder();
        if (houses.getState()!=null) {
            if (builder.length() > 0) {
                builder.append(", ");
            }
            builder.append("state = #{state} ");
        }
        if (houses.getRemark()!=null){
            if (builder.length() > 0) {
                builder.append(", ");
            }
            builder.append("remark = #{remark} ");
        }

        StringBuilder sql = new StringBuilder();
        sql.append("update house set ");
        sql.append(builder);
        sql.append(" WHERE   house_id = #{house_id}; ");

        System.out.println(sql);
        return sql.toString();

    }

}
